package com.wty.cmims.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wty.cmims.pojo.Code;
import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.pojo.Schedule;
import com.wty.cmims.service.ScheduleService;
import com.wty.cmims.mapper.ScheduleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
* @author wty
* @description 针对表【schedule】的数据库操作Service实现
* @createDate 2024-11-23 16:28:23
*/
@Service
public class ScheduleServiceImpl extends ServiceImpl<ScheduleMapper, Schedule>
    implements ScheduleService{
    @Autowired
    private ScheduleMapper scheduleMapper;
    @Override
    public ResponseResult<Map<String, Object>> schedulesFind(Map<String,Object> paramsMap) {
        ResponseResult<Map<String, Object>> responseResult = new ResponseResult<>();
        List<Map<String, Object>> list = new ArrayList<>();
        List<Integer> doctorIds = (List<Integer>) paramsMap.get("doctorIds");
        for(Integer doctorId : doctorIds){
            paramsMap.put("doctorId", doctorId);
            List<Map<String, Object>> doctorSchedule = scheduleMapper.findSchedules(paramsMap);
            list.addAll(doctorSchedule);
        }
        if (!list.isEmpty()) {
            responseResult.setCode(Code.SUCCESS);
            responseResult.setMessage("查询医生排班信息成功");
            responseResult.setDatas(list);
        } else {
            responseResult.setCode(Code.ERROR);
            responseResult.setMessage("查询医生排班信息失败");
        }
        return responseResult;
    }
}




